package day07_14.day08;

import java.util.*;

public class Main01 {
    public static void main(String[] args) {
        Map<String , Integer> map = new HashMap<>();
        List<String> list = new ArrayList<>();
        Scanner scn = new Scanner(System.in);

            String s = scn.nextLine();
            list.add(s);
            map.put(s , s.length());


        int judge1 = 1;
        int judge2 = 1;

        List<String> list1 = new ArrayList<>(list);
        List<String> list2 = new ArrayList<>(list);

        sortLength(list1 , map);
        sortZiDian(list2);
        for (int i = 0; i < list.size(); i++) {
            if (!list.get(i).equals(list1.get(i))){
                judge1 = 0;
            }
            if (!list.get(i).equals(list2.get(i))){
                judge2 = 0;
            }
        }
        if (judge1 == 1 ){
            if (judge2 == 1){
                System.out.println("both");
            }else {
                System.out.println("lengths");
            }
        }else {
            if (judge2 == 1){
                System.out.println("lexicographically");
            }else {
                System.out.println("none");
            }
        }

    }
    public static void sortLength(List<String> list , Map<String , Integer> map){
        list.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return map.get(o1) - map.get(o2);
            }
        });
    }
    public static void sortZiDian(List<String> list){
        list.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.compareTo(o2);
            }
        });
    }

}
